package com.navinfo.opentsp.platform.computing.dto;


import com.navinfo.opentsp.platform.computing.util.EntityConvert;
import com.navinfo.opentsp.platform.location.protocol.common.LCPredictiveMaintenance;

public class MaintenanceEvent3Dto {

   private int	oNGearStatus;	//ON档状态0:关闭；1：打开
   private int	ambientTemperature;	 //环境温度(摄氏度)
   private int	stationaryLoopAir;	//驻挂回路气压指示（kPa）
   private int	frontLoopAir;	//前回路气压指示（kPa）
   private int	rearLoopAir;	//后回路气压指示（kPa）


    public int getoNGearStatus() {
        return oNGearStatus;
    }

    public void setoNGearStatus(int oNGearStatus) {
        this.oNGearStatus = oNGearStatus;
    }

    public int getAmbientTemperature() {
        return ambientTemperature;
    }

    public void setAmbientTemperature(int ambientTemperature) {
        this.ambientTemperature = ambientTemperature;
    }

    public int getStationaryLoopAir() {
        return stationaryLoopAir;
    }

    public void setStationaryLoopAir(int stationaryLoopAir) {
        this.stationaryLoopAir = stationaryLoopAir;
    }

    public int getFrontLoopAir() {
        return frontLoopAir;
    }

    public void setFrontLoopAir(int frontLoopAir) {
        this.frontLoopAir = frontLoopAir;
    }

    public int getRearLoopAir() {
        return rearLoopAir;
    }

    public void setRearLoopAir(int rearLoopAir) {
        this.rearLoopAir = rearLoopAir;
    }

    public static MaintenanceEvent3Dto parseProto(LCPredictiveMaintenance.MaintenanceEvent3 maintenanceEvent3){
        MaintenanceEvent3Dto maintenanceEvent3Dto = new MaintenanceEvent3Dto();
        maintenanceEvent3Dto.setoNGearStatus(maintenanceEvent3.getONGearStatus());
        maintenanceEvent3Dto.setAmbientTemperature(maintenanceEvent3.getAmbientTemperature());
        maintenanceEvent3Dto.setStationaryLoopAir(maintenanceEvent3.getStationaryLoopAir());
        maintenanceEvent3Dto.setFrontLoopAir(maintenanceEvent3.getFrontLoopAir());
        maintenanceEvent3Dto.setRearLoopAir(maintenanceEvent3.getRearLoopAir());


        return maintenanceEvent3Dto;
    }

    /**
     * 解析成String拼接字符串
     * @param maintenanceEvent3
     * @return
     */
    public static String parseString(LCPredictiveMaintenance.MaintenanceEvent3 maintenanceEvent3){
        return EntityConvert.convert(
               maintenanceEvent3.getONGearStatus(),
                maintenanceEvent3.getAmbientTemperature(),
                maintenanceEvent3.getStationaryLoopAir(),
                maintenanceEvent3.getFrontLoopAir(),
                maintenanceEvent3.getRearLoopAir()
        );
    }

    /**
     * 反解析成PB对象
     * @param str
     * @return
     */
    public static LCPredictiveMaintenance.MaintenanceEvent3 parsePB(String str){
        LCPredictiveMaintenance.MaintenanceEvent3.Builder builder = null;

        try{
            String[] revert = EntityConvert.revert(str);
            if(null!=revert && revert.length>=5){
                builder =LCPredictiveMaintenance.MaintenanceEvent3.newBuilder();
                builder.setONGearStatus(Integer.valueOf(revert[0]));
                builder.setAmbientTemperature(Integer.valueOf(revert[1]));
                builder.setStationaryLoopAir(Integer.valueOf(revert[2]));
                builder.setFrontLoopAir(Integer.valueOf(revert[3]));
                builder.setRearLoopAir(Integer.valueOf(revert[4]));

            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return builder==null? null : builder.build();
    }

}
